package com.itheima.service;

import com.itheima.mapper.FoodListMapper;
import com.itheima.pojo.Food;
import com.itheima.pojo.Foodattribute;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 林晓伟
 */
@Service
public class FoodListService {
    @Resource
    private FoodListMapper foodListMapper;

    /**
     * F14-菜品列表
     *
     * @param categoryId 分类Id
     * @param status     状态
     */
    public List<Food> a(String categoryId, Integer status) {
        List<String> id = foodListMapper.id(categoryId);
        List<Food> a = foodListMapper.a(categoryId, status);
        for (String s : id) {
            List<Foodattribute> b = foodListMapper.b(s);
            for (Food food : a) {
                food.setFlavors(b);
            }
        }
        return a;
    }
}
